From 0d8907b04950b007876f787df51b4cba595cd2ed Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 12 Jan 2010 07:03:14 +0000 Subject: [PATCH] libxenlight: do not try to set memory target with a number we haven't verified in set-mem. checking that memory string conversion what done properly instead of sending a request to balloon a domain to 0 memory. Signed-off-by: Vincent Hanquez --- tools/libxl/xl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c index 2322ce4a67..90896f3e08 100644 --- a/tools/libxl/xl.c +++ b/tools/libxl/xl.c @@ -993,6 +993,8 @@ void set_memory_target(char *p, char *mem) { struct libxl_ctx ctx; uint32_t domid; + uint32_t memorykb; + char *endptr; if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { fprintf(stderr, "cannot init xl context\n"); @@ -1004,7 +1006,13 @@ void set_memory_target(char *p, char *mem) fprintf(stderr, "%s is an invalid domain identifier\n", p); exit(2); } - libxl_set_memory_target(&ctx, domid, atoi(mem)); + memorykb = strtoul(mem, &endptr, 10); + if (*endptr != '\0') { + fprintf(stderr, "invalid memory size: %s\n", mem); + exit(3); + } + printf("setting domid %d memory to : %d\n", domid, memorykb); + libxl_set_memory_target(&ctx, domid, memorykb); } int main_memset(int argc, char **argv) -- 2.30.2